def L(num, i):
    for j in range(i + 1, len(num)):
        max1 = L(num, j)
        if max1 is None:
            max1 = 0
        print(num[j],max1,"i是",i,'j是',j)
        return max(num[j], num[j] + max1)


def maxsum(num):
    return max(L(num, i) for i in range(0, len(num) - 1))


a = [3, -4, 2, -1, 2, 6, -5, 4]

print(maxsum(a))
